function getCurrentPage() {
    var pages = getCurrentPages();
    return pages[pages.length - 1];
}

Object.defineProperty(exports, "__esModule", {
    value: !0
});

var dialogInstances = [], showDialog = function showDialog(options) {
    options = Object.assign({}, showDialog.currentOptions, options);
    return new Promise(function(resolve, reject) {
        var dialogComponent = (options.context || getCurrentPage()).selectComponent(options.selector);
        delete options.selector;
        dialogComponent ? (dialogComponent.set(Object.assign({
            onCancel: reject,
            onConfirm: resolve
        }, options)), dialogInstances.push(dialogComponent)) : console.warn("未找到 van-dialog 节点，请确认 selector 及 context 是否正确");
    });
};

showDialog.defaultOptions = {
    show: !0,
    title: "",
    message: "",
    zIndex: 100,
    overlay: !0,
    className: "",
    asyncClose: !1,
    messageAlign: "",
    transition: "scale",
    selector: "#van-dialog",
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    showConfirmButton: !0,
    showCancelButton: !1,
    closeOnClickOverlay: !1,
    confirmButtonOpenType: ""
}, (showDialog.alert = showDialog).confirm = function(options) {
    return showDialog(Object.assign({
        showCancelButton: !0
    }, options));
}, showDialog.close = function() {
    dialogInstances.forEach(function(dialog) {
        dialog.close();
    }), dialogInstances = [];
}, showDialog.stopLoading = function() {
    dialogInstances.forEach(function(dialog) {
        dialog.stopLoading();
    });
}, showDialog.setDefaultOptions = function(options) {
    Object.assign(showDialog.currentOptions, options);
}, showDialog.resetDefaultOptions = function() {
    showDialog.currentOptions = Object.assign({}, showDialog.defaultOptions);
}, showDialog.resetDefaultOptions(), exports.default = showDialog;